Blog

Hyper Updates - June 2023

Eric Peterson June 16, 2023

Spread the word

Eric Peterson

June 16, 2023

Spread the word


Share your thoughts

There's been lots of updates to Hyper this month, including not one but two breaking changes! (Trying to stick to semver here, even when the breaking changes seem minor.)

New Documentation Site

Perhaps the most exciting news, Hyper has a new home for documentation! We outgrew using just a README a while ago and now we finally have a brand new home for Hyper. This will make finding the documentation you need even easier.

Next to the headline new features:

asXML support

Hyper now has built-in support for dealing with XML apis using the asXML helper method.

head and options shortcut methods

Need to make head or options? Now you can do it without having to call setMethod first.

More Accurate Status Codes

Hyper now returns more accurate status codes for 502 Bad Gateway and 408 Request Timeout responses. Previously, these responses were returned as 504 Gateway Timeout responses. Hyper now normalizes the responses from the different CFML engines into a consistent response. 502 Bad Gateway is returned instead of 504 Gateway Timeout for invalid hosts. 408 Request Timeout is returned if the request takes longer than the configured timeout value.

Easier Custom Hyper Clients

It is now more straightforward to register a custom Hyper client. Inside your config/WireBox.cfc in an afterAspectsLoad method, you can get a reference to a HyperBuilder, configure it as you would for a request, and then call the registerAs method passing in your desired WireBox alias.

// config/WireBox.cfc
component {

   // ...
   
   function afterApsectsLoad() {
       injector.getInstance( "HyperBuilder@hyper" )
           .setBaseUrl( "https://api.github.com" )
           .asJson()
           .withHeaders( {
               "Authorization": coldbox.getUtil().getSystemSetting( "GITHUB_TOKEN" )
           } )
           .registerAs( "GitHubClient" );
   }

}

This is a welcome improvement as the init arguments do not exactly match the method names. Also, for defaults like requestCallbacks, responseCallbacks, or even queryParams, passing in arrays of functions or arrays or structs is not as straightforward as calling the related methods. Now, you can use the Hyper methods you are familiar with when registering your custom Hyper clients.

Faking Requests

We kind of buried the lead here, but Hyper now ships with the ability to fake requests for testing.

Here's a quick example:

hyper.fake( {
    "https://google.com/*": function( newFakeResponse, req ) {
         return newFakeResponse( 404, "Not Found" );
    }
} );

var resA = hyper.get( "https://google.com" );
expect( resA.getStatus() ).toBe( "404 Not Found" );

var resB = hyper.get( "https://does-not-exist.also-does-not-exist" );
expect( resB.getStatus() ).toBe( "200 OK" );

There's a lot to love here, so make sure to give the documentation a visit.

We hope you love these updates to Hyper! Happy HTTP'ing!

Add Your Comment

Recent Entries

Ortus Solutions Brings Innovation with BoxLang as Platinum Sponsor and Keynote Presenter at CFCamp 2025!

Ortus Solutions Brings Innovation with BoxLang as Platinum Sponsor and Keynote Presenter at CFCamp 2025!

Join us for groundbreaking workshops and discover the future of modern development with BoxLang.

Ortus Solutions is thrilled to announce its participation as a Platinum Sponsor and Keynote Presenter at CFCamp 2025, the premier conference for modern web development! Held at the Atomis Hotel Munich Airport by Mercure in Oberding, Germany, on May 22–23, 2025, this event is a must-attend for developers and tech enthusiasts.

As the...

Cristobal Escobar
Cristobal Escobar
December 03, 2024
BoxLang Monthly Newsletter - November Recap 2024

BoxLang Monthly Newsletter - November Recap 2024

This month, we’re excited to share the latest developments, updates, and opportunities from the BoxLang ecosystem. From groundbreaking beta releases to insightful new tools and community highlights, there’s something for every modern web developer.

Dive into our November Recap to explore how BoxLang is shaping the future of web development and discover ways to get involved. Don’t miss exclusive content, upcoming events, and special offers designed to keep you ahead of the curve in the JVM ecosystem.

Maria Jose Herrera
Maria Jose Herrera
December 02, 2024
How a ColdFusion Security Audit Can Protect Your Business from Data Breaches

How a ColdFusion Security Audit Can Protect Your Business from Data Breaches

In today’s digital landscape, security threats are evolving at an alarming rate, and your business’s ColdFusion application—whether powered by Lucee or Adobe ColdFusion—may be more vulnerable than you think. A comprehensive ColdFusion security audit is essential to safeguarding sensitive data, maintaining compliance, and protecting your organization from potential cyberattacks.

Why is a ColdFusion Security Audit Critical?

Security should be a top priority for any business oper...

Cristobal Escobar
Cristobal Escobar
December 02, 2024